/**
 * 2016年11月1日
 */
package jdk.effectivejava;
/**
 * @author Alex
 *
 */
interface Operation{
	double apply(double x,double y);
}
enum ExOp implements Operation{
	REMAINDER("%")//{
//		public double apply(double x,double y){
//			return x%y;
//		}
	//},
	,
	EXP("^"){
//		public double apply(double x,double y){
//				return Math.pow(x, y);
//		}
	};
	private String symbol;
	public String toString(){
		return symbol;
	}
	private ExOp(String s) {
		this.symbol = s;
	}
	public double apply(double x,double y){
		return x-2*y;
	}
}
public class EnumTest {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		test(ExOp.class,2,2);
	}
	private static <T extends Enum<T> & Operation> void test(Class<T>opSet,double x,double y){
		for(Operation op : opSet.getEnumConstants()){
			System.out.println(op.apply(x, y));
		}
	}

}
